home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15151 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  49 lines

  1. Path: newsfeed.ksu.ksu.edu!usenet
  2. From: Iyer <iyer@ksu.ksu.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: (no subject)
  5. Date: 3 Apr 1996 23:00:36 GMT
  6. Organization: Kansas State University
  7. Message-ID: <4juvuk$4vn@newserv.ksu.ksu.edu>
  8. NNTP-Posting-Host: 129.130.81.118
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  13.  
  14. I have a problem in returning a two dimensional array.I have declared it
  15. as a two dimensional pointer in my Matrix class.This is a private 
  16. variable.To access this i have two functions .One is 
  17. void SetMatrixElements(double **mat)
  18. double **GetMatElements();
  19. When i receive this GetMatElements(),i am declaring a double **temp,
  20. then I am receiving in this temp pointer.But i  am not allocating any 
  21. memory for this temp pointer.When i delete the the Matrix object, it's 
  22. mat elements get deleted,but to which this temp is pointing.But i cannot 
  23. delete the temp before i quit the function,this will delete the mat 
  24. elements.So, what shall i do.
  25.  
  26. class Matrix
  27. {
  28.   private:
  29. int nc;int nr; double **mat;
  30. public:
  31. double **GetMatElemnts();
  32. void SetMatElemnts(double **m);
  33.  
  34. }
  35.  
  36.  
  37. Matrix *A;
  38. void Function(){
  39. double **temp;
  40. temp = A->GetMatElements();
  41.  
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  
  48.  
  49.